//定义路由规则(路由表)
const routes = [
    {
      path: '/home',
      name: 'home',
      meta: { title:"首页"  ,require: true},  //title 是当前路由的标题, require:true 表示访问当前路由需要提前登录
      component: () => import('@/views/HomeView.vue')
    },{
      path:'/dizhi',
      name:'dizhi',
      meta: { title: '我的地址' },
      component: () => import('@/views/Where.vue'),
    },
    {
      path:'/search',
      name:'search',
      meta: { title: '搜索' },
      component: () => import('@/views/Search.vue'),
    },
    {
      path: '/tuan',
      meta: { title:"爆爆团" },
      name: 'tuan',
      component: () => import('@/views/Tuan.vue'),
      children: [
        {
            path: '/tuan/nowbuy',
            name: 'nowbuy',
            meta: { title: '正在购买' },
            component: () => import('@/views/Tuan/Nowbuy.vue'),
        },
        {
            path: '/tuan/coming',
            name: 'coming',
            meta: { title: '即将上新' },
            component: () => import('@/views/Tuan/Coming.vue'),
        },
        {
            //重定向
            path: '/tuan',
            meta: { title: '爆爆团' },
            redirect: '/tuan/nowbuy'
        }
    ]
    },
    {
      path: '/order',
      meta: { title:"订单" },
      name: 'order',
      component: () => import('@/views/Order.vue')
    },
    {
      path: '/mysc',
      meta: { title:"我的收藏" },
      name: 'mysc',
      component: () => import('@/views/Mysc.vue')
    },
    {
      path: '/my',
      meta: { title:"我的" },
      name: 'my',
      component: () => import('@/views/My.vue')
    },
    {
      path:"/login",
      meta: { title:"登陆" }, //路由元信息( 会永远跟着当前路由 )
      name:"login",
      component: () => import('@/views/Login.vue')
    },
    {
      path:"/register",
      meta: { title:"注册" },
      name:"register",
      component: () => import('@/views/Register.vue')
    },
    {
      //  /detail/893650805197346
      //  /detail/998912192123122
      //path:"/detail/:id",  //动态路由, id是动态路由的参数, 这个参数可以在 Detail 组件中获取
      path:"/detail",  
      meta: { title:"详情" ,require: true},
      name:"detail",
      component: () => import('@/views/Detail.vue'),
      beforeEnter:(to,from,next)=>{
        next();
      }
    },
    {
      path:"/",
      redirect:"/login"
    }
]

export default routes;